package com.qs.questionnairesurveysystem.service.impl;

import com.qs.questionnairesurveysystem.entity.Answer;
import com.qs.questionnairesurveysystem.mapper.AnswerMapper;
import com.qs.questionnairesurveysystem.service.AnswerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AnswerServiceImpl implements AnswerService {

    @Autowired
    private AnswerMapper answerMapper;

    // 创建新答案
    @Override
    public void createAnswer(Answer answer) {
        answerMapper.insertAnswer(answer);
    }

    // 更新答案
    @Override
    public void updateAnswer(Answer answer) {
        answerMapper.updateAnswer(answer);
    }

    // 删除答案
    @Override
    public void deleteAnswer(Long answerId) {
        answerMapper.deleteAnswer(answerId);
    }

    // 获取指定答案
    @Override
    public Answer getAnswerById(Long answerId) {
        return answerMapper.getAnswerById(answerId);
    }

    // 获取所有答案
    @Override
    public List<Answer> getAllAnswers() {
        return answerMapper.getAllAnswers();
    }

    // 根据问卷ID获取答案
    @Override
    public List<Answer> getAnswersBySurveyId(Long surveyId) {
        return answerMapper.getAnswersBySurveyId(surveyId);
    }

    // 根据问题ID获取答案
    @Override
    public List<Answer> getAnswersByQuestionId(Long questionId) {
        return answerMapper.getAnswersByQuestionId(questionId);
    }

    @Override
    public List<Answer> getAnswersBySurveyIdUid(Long surveyId, Long uid) {
        return answerMapper.getAnswersBySurveyIdUid(surveyId,uid);
    }


}
